package com.fwtai.web;

import com.fwtai.datasource.DaoHandle;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;

/**
 * 删除超时的订单
 * @作者 田应平
 * @版本 v1.0
 * @创建时间 2021-08-10 11:19:15
 * @QQ号码 444141300
 * @Email service@yinlz.com
 * @官网 <url>http://www.fwtai.com</url>
*/
@Repository
public class TaskHandlerDao{

  private final DaoHandle dao;

  public TaskHandlerDao(final DaoHandle dao){
    this.dao = dao;
  }

  //获取下单时间大于40分钟的未支付订单
  public List<Long> getTimeoutOrder(){
    return dao.queryListEntity("task_handler.getTimeoutOrder");
  }

  //获取下单时间大于35分钟的未支付订单
  public List<Long> getMallTimeoutOrder(){
    return dao.queryListEntity("task_handler.getMallTimeoutOrder");
  }

  public Long getOrderStatus(final long kid){
    return dao.queryForLong("task_handler.getOrderStatus",kid);
  }

  public Long getMallOrderStatus(final long out_trade_no){
    return dao.queryForLong("task_handler.getMallOrderStatus",out_trade_no);
  }

  //删除已超时的服务订单
  public int delTimeoutOrder(final List<Long> list){
    return dao.execute("task_handler.delOrderInfo",list);//先删除 goods_order_detail、goods_order_log、最后再删除 goods_order
  }

  //删除已超时的积分商城的全部订单
  public int delTimeoutMallOrder(final List<Long> list){
    return dao.execute("task_handler.delTimeoutMallOrder",list);//先删除 goods_order_detail、goods_order_log、最后再删除 goods_order
  }

  public List<HashMap<String,Object>> getOrderConfirmed(){
    return dao.queryForListHashMap("task_handler.getOrderConfirmed");
  }

  public List<HashMap<String,Object>> getMallOrder(){
    return dao.queryForListHashMap("task_handler.getMallOrder");
  }
}